package com.neusoft.tyut.ad;

import java.util.ArrayList;
import java.util.List;

public class MyStackAdapter implements  IStack<String>{
    private  final List<String>  list = new ArrayList<>();
    @Override
    public void push(String t) {
        list.add(t);
    }

    @Override
    public String pop() {
        assert !isEmpty();
        String s =  peek();
        list.remove(list.size()-1);
        return s ;
    }

    @Override
    public String peek() {
        assert !isEmpty();
        String s =  list.get(   list.size()-1  );
        return s ;
    }

    @Override
    public int size() {
        return list.size();
    }

    @Override
    public boolean isEmpty() {
        return size() == 0;
    }
}
